| Total Complexity | 2 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 19 | |||
| 20 | @Controller('tasks') |
||
| 21 | @ApiTags('Task') |
||
| 22 | @ApiBearerAuth() |
||
| 23 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
| 24 | export class UpdateTaskAction { |
||
| 25 | constructor( |
||
| 26 | @Inject('ICommandBus') |
||
| 27 | private readonly commandBus: ICommandBus |
||
| 28 | ) {} |
||
| 29 | |||
| 30 | @Put(':id') |
||
| 31 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
| 32 | @ApiOperation({summary: 'Update task'}) |
||
| 33 | public async index(@Param() dto: IdDTO, @Body() taskDto: TaskDTO) { |
||
| 34 | try { |
||
| 35 | const {id} = dto; |
||
| 36 | await this.commandBus.execute(new UpdateTaskCommand(id, taskDto.name)); |
||
| 37 | |||
| 38 | return {id}; |
||
| 39 | } catch (e) { |
||
| 40 | throw new BadRequestException(e.message); |
||
| 41 | } |
||
| 44 |